<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Returns a new identity transform.
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * @class Represents a transformation matrix. The transformation matrix is
<span class='line'>  5</span>  * limited to expressing translate and uniform scale transforms only; shearing,
<span class='line'>  6</span>  * rotation, general affine, and other transforms are not supported.
<span class='line'>  7</span>  *
<span class='line'>  8</span>  * &lt;p>The methods on this class treat the transform as immutable, returning a
<span class='line'>  9</span>  * copy of the transformation matrix with the specified transform applied. Note,
<span class='line'> 10</span>  * alternatively, that the matrix fields can be get and set directly.
<span class='line'> 11</span>  */</span><span class="WHIT">
<span class='line'> 12</span> </span><span class="NAME">pv.Transform</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 13</span> </span><span class="NAME">pv.Transform.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">k</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 14</span> 
<span class='line'> 15</span> </span><span class="COMM">/**
<span class='line'> 16</span>  * The scale magnitude; defaults to 1.
<span class='line'> 17</span>  *
<span class='line'> 18</span>  * @type number
<span class='line'> 19</span>  * @name pv.Transform.prototype.k
<span class='line'> 20</span>  */</span><span class="WHIT">
<span class='line'> 21</span> 
<span class='line'> 22</span> </span><span class="COMM">/**
<span class='line'> 23</span>  * The x-offset; defaults to 0.
<span class='line'> 24</span>  *
<span class='line'> 25</span>  * @type number
<span class='line'> 26</span>  * @name pv.Transform.prototype.x
<span class='line'> 27</span>  */</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> </span><span class="COMM">/**
<span class='line'> 30</span>  * The y-offset; defaults to 0.
<span class='line'> 31</span>  *
<span class='line'> 32</span>  * @type number
<span class='line'> 33</span>  * @name pv.Transform.prototype.y
<span class='line'> 34</span>  */</span><span class="WHIT">
<span class='line'> 35</span> 
<span class='line'> 36</span> </span><span class="COMM">/**
<span class='line'> 37</span>  * @private The identity transform.
<span class='line'> 38</span>  *
<span class='line'> 39</span>  * @type pv.Transform
<span class='line'> 40</span>  */</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="NAME">pv.Transform.identity</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Transform</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> 
<span class='line'> 43</span> </span><span class="COMM">// k 0 x   1 0 a   k 0 ka+x</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="COMM">// 0 k y * 0 1 b = 0 k kb+y</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="COMM">// 0 0 1   0 0 1   0 0 1</span><span class="WHIT">
<span class='line'> 46</span> 
<span class='line'> 47</span> </span><span class="COMM">/**
<span class='line'> 48</span>  * Returns a translated copy of this transformation matrix.
<span class='line'> 49</span>  *
<span class='line'> 50</span>  * @param {number} x the x-offset.
<span class='line'> 51</span>  * @param {number} y the y-offset.
<span class='line'> 52</span>  * @returns {pv.Transform} the translated transformation matrix.
<span class='line'> 53</span>  */</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="NAME">pv.Transform.prototype.translate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Transform</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">  </span><span class="NAME">v.k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">  </span><span class="NAME">v.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">  </span><span class="NAME">v.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> 
<span class='line'> 62</span> </span><span class="COMM">// k 0 x   d 0 0   kd  0 x</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="COMM">// 0 k y * 0 d 0 =  0 kd y</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="COMM">// 0 0 1   0 0 1    0  0 1</span><span class="WHIT">
<span class='line'> 65</span> 
<span class='line'> 66</span> </span><span class="COMM">/**
<span class='line'> 67</span>  * Returns a scaled copy of this transformation matrix.
<span class='line'> 68</span>  *
<span class='line'> 69</span>  * @param {number} k
<span class='line'> 70</span>  * @returns {pv.Transform} the scaled transformation matrix.
<span class='line'> 71</span>  */</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="NAME">pv.Transform.prototype.scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Transform</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">  </span><span class="NAME">v.k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">  </span><span class="NAME">v.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">  </span><span class="NAME">v.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> 
<span class='line'> 80</span> </span><span class="COMM">/**
<span class='line'> 81</span>  * Returns the inverse of this transformation matrix.
<span class='line'> 82</span>  *
<span class='line'> 83</span>  * @returns {pv.Transform} the inverted transformation matrix.
<span class='line'> 84</span>  */</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="NAME">pv.Transform.prototype.invert</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Transform</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">  </span><span class="NAME">v.k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">  </span><span class="NAME">v.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">this.x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">  </span><span class="NAME">v.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">this.y</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 92</span> 
<span class='line'> 93</span> </span><span class="COMM">// k 0 x   d 0 a   kd  0 ka+x</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="COMM">// 0 k y * 0 d b =  0 kd kb+y</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="COMM">// 0 0 1   0 0 1    0  0    1</span><span class="WHIT">
<span class='line'> 96</span> 
<span class='line'> 97</span> </span><span class="COMM">/**
<span class='line'> 98</span>  * Returns this matrix post-multiplied by the specified matrix &lt;i>m&lt;/i>.
<span class='line'> 99</span>  *
<span class='line'>100</span>  * @param {pv.Transform} m
<span class='line'>101</span>  * @returns {pv.Transform} the post-multiplied transformation matrix.
<span class='line'>102</span>  */</span><span class="WHIT">
<span class='line'>103</span> </span><span class="NAME">pv.Transform.prototype.times</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Transform</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">  </span><span class="NAME">v.k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">m.k</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">  </span><span class="NAME">v.x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">m.x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">  </span><span class="NAME">v.y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.k</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">m.y</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span></pre></body></html>